package com.data.boot.config;


import com.data.boot.service.LoadDataService;
import com.data.boot.service.LoadDataServiceFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by dwk on 2019/6/4.
 */
@Configuration
public class FactoryConfig {
    @Autowired
    private LoadDataService mySqlLoadDataService;
    @Autowired
    private LoadDataService sqlServerLoadDataService;

    @Bean
    public LoadDataServiceFactory createFactory() {
        LoadDataServiceFactory factory = LoadDataServiceFactory.getLoadDataServiceFactory();
        Map<String, LoadDataService> serviceMap = new HashMap<>();
        serviceMap.put("mysql", mySqlLoadDataService);
        serviceMap.put("sqlServer", sqlServerLoadDataService);
        factory.setMap(serviceMap);
        return factory;
    }
}
